<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>社区养老服务信息系统</title>
	</head>
	<link rel="stylesheet" type="text/css" href="../js/layui/css/layui.css"/>
	<script src="../js/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/JQuery.js" type="text/javascript" charset="utf-8"></script>
	<style type="text/css">
		body{background-color: white;font-family: "Microsoft Yahei";font-size: 16px;margin: auto;}
		.title{display: inline-block; font-size: 30px;font-weight: bold;margin-top: 10px;margin-left: 150px;}
		.list{margin: auto;background-color: antiquewhite;padding-left: 700px;}
		.type{display: inline-block;padding-left: 100px;}
		.test{width: 2000px;height: 2000px;background-color: #0000FF;display: block;position: absolute;}
		.one{display:none}
		.two{display:none}
		.three{display:none;z-index: 1;width: 400px;height: 400px;border-color: #000000;margin: auto;border-radius: 10px;position: relative;top: 0px;right: 100px;background-color: white;opacity: 0.9;}
		.head{display: block;text-align: center;font-size: 28px;font-weight: bold;padding-top: 30px;}
		.unite{margin-top: 10px;font-size: 20px;margin-left: 50px;}
		.unite div:nth-child(1){display: inline-block;width: 90px;margin-left: 10px;}
		.unite div:nth-child(2){display: inline-block;width: 100px;}
		.unite div:nth-child(3){display: inline-block;width: 90px;}
		.layui-btn-normal{margin: auto;display: block;width: 200px;margin-top: 20px;}
		.mengceng{display:none;background-color:gray;left:0;opacity: 0.5;position: absolute;top: 0;z-index: 1;width: 100%;height: 100%;}
	</style>
	<body>
		<div class="mengceng"></div>
		<div class="heads">
			<span class="title">社区养老服务信息系统</span>
			<span class="type">登录类型：</span>
			<span>管理员</span>
			<span class="type">账号：</span>
			<span>${account_id }</span>
		</div>
		<div>
			<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
			  <ul class="layui-tab-title list">
			    <li id="mara">账户管理</li>
			    <li id="mara2">老人健康查询</li>
				<li id="mara3">密码修改</li>
			  </ul>
			  <div class="layui-tab-content"></div>
			</div> 
		</div>
		
		
		<div class="one">
		<button type="button" class="selects" style="display: inline-block; width: 80px; height: 30px; position: relative; left: 400px; top: 0px">账号查询</button>
			<div
				style="display: inline-block; width: 50px; height: 30px; position: relative; left: 400px; top: 0px">
				<input type="text" class="account_ids" style="display: inline-block;"></div>
			<table class="layui-table table">
			  <colgroup>
			    <col width="150">
			    <col width="200">
			    <col>
			  </colgroup>
			  <thead>
			    <tr>
			      <th>账号</th>
			      <th>密码</th>
			      <th>账号类型</th>
				  <th>持有人编号</th>
				  <th>操作</th>
			    </tr> 
			  </thead>
			  <tbody id="fenye">
			  </tbody>
			</table>
			<div class="first"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">首页</div>
			<div class="prev"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">上一页</div>
			<div class="next"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">下一页</div>
			<div class="last "
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">尾页</div>
			<div class="indexpage"
				style="display: inline-block; width: 150px; height: 100px; position: relative; left: 400px; top: 20px"></div>
			<button type="button" class="jump" style="display: inline-block; width: 60px; height: 30px; position: relative; left: 400px; top: 20px">跳转至</button>
			<div class="jump1"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">
				<input type="text" class="jumppage" style="display: inline-block;"></div>
		</div>
		
		<div class="two">
		<button type="button" class="selects2" style="display: inline-block; width: 80px; height: 30px; position: relative; left: 400px; top: 0px">健康查询</button>
			<div
				style="display: inline-block; width: 50px; height: 30px; position: relative; left: 400px; top: 0px">
				<input type="text" class="oldpeople_name" style="display: inline-block;"></div>
			<table class="layui-table table2">
			  <colgroup>
			    <col width="150">
			    <col width="200">
			    <col>
			  </colgroup>
			  <thead>
			    <tr>
			      <th>疾病id</th>
			      <th>疾病名</th>
			      <th>疾病参数</th>
				  <th>老人id</th>
				  <th>老人名字</th>
				  <th>老人电话</th>
				  <th>家人电话</th>
			    </tr> 
			  </thead>
			  <tbody id="fenye2">
			  </tbody>
			</table>
			<div class="first2"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">首页</div>
			<div class="prev2"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">上一页</div>
			<div class="next2"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">下一页</div>
			<div class="last2 "
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">尾页</div>
			<div class="indexpage2"
				style="display: inline-block; width: 150px; height: 100px; position: relative; left: 400px; top: 20px"></div>
			<button type="button" class="jump2" style="display: inline-block; width: 60px; height: 30px; position: relative; left: 400px; top: 20px">跳转至</button>
			<div class="jump21"
				style="display: inline-block; width: 50px; height: 100px; position: relative; left: 400px; top: 20px">
				<input type="text" class="jumppage2" style="display: inline-block;"></div>
		</div>
		<div class="three" style="position: relative;top: 100px">
			<div class="login_body">
					<div class="login_yonghumings unite">
						<span class="login_yonghuming">原&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
						<input type="password" name="" id="password11" value="" placeholder="原密码" maxlength="20"/>
					</div>
					<div class="login_mimas unite">
						<span class="login_mima">新&nbsp;&nbsp;密&nbsp;&nbsp;码：</span>
						<input type="password" name="" id="password22" value="" placeholder="新密码" maxlength="20"/>
					</div>
					<div class="login_mimas unite">
						<span class="login_mima">确认&nbsp;密码：</span>
						<input type="password" name="" id="password33" value="" placeholder="确认密码" maxlength="20"/>
					</div>
					<button class="layui-btn layui-btn-normal">修改</button>
				</div>
		</div>
		<div class="bottom" style="display: block;width: 100%;height: 70px;background-color: antiquewhite;position: absolute;bottom: 0;font-size: 12px">
			<span style="display: block;position: absolute;top: 15px;left: 38%;">如遇问题欢迎致电  热线电话：15979292103 阳雨晨 版权所有</span>
				<span style="display: block;position: absolute;top: 40px;left: 40%;">Copyright © 2020 Create By YangYuChen </span>
		</div>
	</body>
	<script>
		$(function(){
			$("#mara").click(function(){
				var pagesum=0;//总页数
				var page=0;//当前页数-1
				var temp=0;//根据数据总数和余数获取for循环的循环次数
				$(".two").css({display:"none"});
				$(".three").css({display:"none"});
				$(".one").css({display:"block"});
				$.post("${pageContext.request.contextPath}/consumer/getPageSum",{},function(data){
					data = eval(data); 
					pagesum=data;
				});
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});
				$(".next").click(function(){
				if(page+1<pagesum){
					page=page+1;
				}else{
					page=page;
				}
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".prev").click(function(){
				if(page>0){
					page=page-1;
				}else{
					page=page;
				} 
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
					data = eval(data); 
					var content="";
					temp=data.length;
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".first").click(function(){
				page=0; 
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:1},function(data){
					data = eval(data); 
					var content="";
					temp=data.length;
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".last").click(function(){
					page=pagesum-1;
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:pagesum},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".jump").click(function(){
					if($(".jumppage").val()>pagesum){
						alert("超过最大页数")
					}else{
						page=$(".jumppage").val()-1;
					}
				$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
					}
					$("#fenye").html(content);
					$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$("#fenye").delegate(".butt","click",function(){
					var string =$(this).val();
					var strs = new Array(); //定义一数组
					strs = string.split("|"); //字符分割
					var account_id=strs[0];
					var account_type=strs[1];
					if(account_type==4||account_type=="4"){
						account_type=1;
					}
					if(account_type==5||account_type=="5"){
						account_type=2;
					}
					if(account_type==6||account_type=="6"){
						account_type=3;
					}
					var params={
							account_id:account_id,
							account_type:account_type
					};
					$.post("${pageContext.request.contextPath}/consumer/updateAccountType",params,function(data){
						if(data == "true"|| data==true){
							alert("修改成功");
							$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
								data = eval(data); 
								var content="";
								temp=data.length;
								for(var i = 0;i<temp;i++){
									content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
								}
								$("#fenye").html(content);
								$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
							});
						}else{
							alert("修改失败");
						}
					});
				});
				$("#fenye").delegate(".delete","click",function(){
					var string =$(this).val();
					var strs = new Array(); //定义一数组
					strs = string.split("|"); //字符分割
					var account_id=strs[0];
					var account_type=strs[1];
					if(account_type==1||account_type=="1"){
						account_type=4;
					}
					if(account_type==2||account_type=="2"){
						account_type=5;
					}
					if(account_type==3||account_type=="3"){
						account_type=6;
					}
					var params={
							account_id:account_id,
							account_type:account_type
					};
					$.post("${pageContext.request.contextPath}/consumer/updateAccountType",params,function(data){
						if(data == "true"|| data==true){
							alert("修改成功");
							$.post("${pageContext.request.contextPath}/consumer/getAllAccount",{page:page+1},function(data){
								data = eval(data); 
								var content="";
								temp=data.length;
								for(var i = 0;i<temp;i++){
									content += "<tr><td>"+data[i].account_id+"</td><td>"+data[i].account_password+"</td><td>"+data[i].account_type+"</td><td>"+data[i].holder_id+"</td><td><button class='butt' value="+data[i].account_id+"|"+data[i].account_type+">注册</button><button class='delete' value="+data[i].account_id+"|"+data[i].account_type+"|"+data[i].account_type+">注销</button></td></tr>";
								}
								$("#fenye").html(content);
								$(".indexpage").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
							});
						}else{
							alert("修改失败");
						}
					});
				});
			});
			$(".selects").click(function(){
				var account_id=$(".account_ids").val();
				$.post("${pageContext.request.contextPath}/consumer/selectAccount",{account_id:account_id},function(data){
					data = eval(data); 
					if(data==undefined){
						alert("未查询到");
					}else{
						var content = "<tr><td>"+data.account_id+"</td><td>"+data.account_password+"</td><td>"+data.account_type+"</td><td>"+data.holder_id+"</td><td><button class='butt' value="+data.account_id+"|"+data.account_type+">注册</button><button class='delete' value="+data.account_id+"|"+data.account_type+"|"+data.account_type+">注销</button></td></tr>";
						$("#fenye").html(content);
						$(".indexpage").html("当前第1页      共1页"); 
					}
				});
			});
			$('#mara').trigger("click");
			$("#mara2").click(function(){
				var pagesum=0;//总页数
				var page=0;//当前页数-1
				var temp=0;//根据数据总数和余数获取for循环的循环次数
				$(".two").css({display:"block"});
				$(".three").css({display:"none"});
				$(".one").css({display:"none"});
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeopleSum",{},function(data){
					data = eval(data); 
					pagesum=data;
				});
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});
				$(".next2").click(function(){
				if(page+1<pagesum){
					page=page+1;
				}else{
					page=page;
				}
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".prev2").click(function(){
				if(page>0){
					page=page-1;
				}else{
					page=page;
				} 
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:page+1},function(data){
					data = eval(data); 
					var content="";
					temp=data.length;
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".first2").click(function(){
				page=0; 
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:1},function(data){
					data = eval(data); 
					var content="";
					temp=data.length;
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".last2").click(function(){
					page=pagesum-1;
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:pagesum},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".jump2").click(function(){
					if($(".jumppage2").val()>pagesum){
						alert("超过最大页数")
					}else{
						page=$(".jumppage2").val()-1;
					}
				$.post("${pageContext.request.contextPath}/consumer/getDieasePeople",{page:page+1},function(data){
					data = eval(data); 
					temp=data.length;
					var content="";
					for(var i = 0;i<temp;i++){
						content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
					}
					$("#fenye2").html(content);
					$(".indexpage2").html("当前第"+(page+1)+"页      共"+pagesum+"页"); 
				});});
				$(".selects2").click(function(){
					var oldpeople_name=$(".oldpeople_name").val();
					$.post("${pageContext.request.contextPath}/consumer/selectDieasepeople",{oldpeople_name:oldpeople_name},function(data){
						data = eval(data); 
						temp=data.length;
						if(temp==0||temp=="0"){
							alert("未查询到");
						}else{
							var content="";
							for(var i = 0;i<temp;i++){
								content += "<tr><td>"+data[i].disease_id+"</td><td>"+data[i].disease_name+"</td><td>"+data[i].disease_parameter+"</td><td>"+data[i].oldpeople_id+"</td><td>"+data[i].oldpeople_name+"</td><td>"+data[i].oldpeople_tel+"</td><td>"+data[i].oldpeople_familytel+"</td></tr>";
							}
							$("#fenye2").html(content);
							$(".indexpage2").html("当前第1页      共1页"); 
						}
					});
				});
			})
			$("#mara3").click(function(){
				var pagesum=0;//总页数
				var page=0;//当前页数-1
				var temp=0;//根据数据总数和余数获取for循环的循环次数
				$(".two").css({display:"none"});
				$(".three").css({display:"block"});
				$(".one").css({display:"none"});
				$(".layui-btn").click(function(){
					var password11=$("#password11").val();
					var account_password=$("#password22").val();
					var password33=$("#password33").val();
					var account_type="3";
					if(account_password==password33){
						var account_id=${account_id};
						var params={
								account_id:account_id,
								account_password:password11,
								account_type:account_type
						};
						$.post("${pageContext.request.contextPath}/consumer/logins",params,function(data){
							data = eval(data); 
							if(data==true||data=="true"){
								$.post("${pageContext.request.contextPath}/consumer/updateAccount",{account_id:account_id,account_password:account_password},function(data){
									data = eval(data); 
									if(data==true||data=="true"){
										window.location="${pageContext.request.contextPath }/jsp/login.jsp";
									}
								});
							}else{
								alert("原密码错误");
							}
						});
					}else{
						alert("确认密码错误");
					}
				})
			});
		})
	</script>
</html>
